<?php

    header('content-type:text/html;charset = utf-8');
    class check{

        public function __construct(){
            
        }
        
        private static $_invalidTags = array(
            '1' => array(
                '百度云升级', 
                '页面不存在 - 百度云', 
                '百度云 网盘-链接不存在',
                '百度云 个人首页-链接不存在'
            ),
            '2' => array('华为网盘|DBank网盘'),
            '3' => array('微盘'),
            '4' => array(
                'Woops!无权访问 - 免费高速下载 - 城通网盘-50TB超大网盘',
                'Woops!找不到文件 - 免费高速下载 - 城通网盘-50TB超大网盘'
            )
        );
        
        public function checkurl($data)
        {
            include 'simple_html_dom.php';
            defined( 'MAX_FILE_SIZE' ) || define( 'MAX_FILE_SIZE', 600000 );
            header('Content-type: text/html;charset=utf-8');
            $html   = file_get_html($data['url'], $data);
            if(empty($html) || !$html){
                $this->unsetHtml($html);
                return 0;
            }
            foreach ($html->find('title') as $element) {
                $title = $element->plaintext;
                break;
            }
            $invalidValues = self::$_invalidTags[$data['siteid']];
            if(empty($invalidValues) || empty($title)){
                $this->unsetHtml($html);
                return 1;
            }
            $result = in_array($title, $invalidValues) ? true : false; 
            $this->unsetHtml($html);
            return 2;
        }
        
        private function unsetHtml($html)
        {
            $html->clear(); 
            unset($html);
        }
    }

?>